package com.personal.system.controller.sys;


import com.personal.common.result.Result;
import com.personal.model.system.SysDept;
import com.personal.system.service.sys.SysDeptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 组织机构 前端控制器
 * </p>
 *
 * @author HD
 * @since 2022-10-29
 */
@RestController
@RequestMapping("/admin/system/sysDept")
public class SysDeptController {

    @Resource
    private SysDeptService deptService;

    //部门列表（树形）
    @ApiOperation("部门列表")
    @GetMapping("findNodes")
    public Result findNodes() {
        List<SysDept> list = deptService.findNodes();
        return Result.ok(list);
    }

    //添加菜单
    @ApiOperation("添加部门")
    @PostMapping("save")
    public Result save(@RequestBody SysDept sysDept) {
        deptService.save(sysDept);
        return Result.ok();
    }

    //修改
    @ApiOperation("修改菜单")
    @PostMapping("update")
    public Result update(@RequestBody SysDept sysDept) {
        deptService.updateById(sysDept);
        return Result.ok();
    }

    //删除菜单
    @ApiOperation("删除菜单")
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable String id) {
        deptService.removeDeptById(id);
        return Result.ok();
    }

}

